﻿<UserControl x:Class="Header.View.HeaderView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:cal="http://www.codeplex.com/CompositeWPF"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"  
             xmlns:commad="clr-namespace:Infrastructure.Commands;assembly=Infrastructure"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <UserControl.Resources>
        <ItemsPanelTemplate x:Key="ItemsPanelTemplate">
            <StackPanel FrameworkElement.MinWidth="150" />
        </ItemsPanelTemplate>
        <Style x:Key="ListViewItemContainerStyle" TargetType="ListBoxItem">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="ListBoxItem">
                        <Grid x:Name="wrapper"  Background="Transparent" Margin="0 0 0 1" Height="43">
                            <Grid x:Name="SelectedVisualState" UIElement.Visibility="Collapsed" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                                <Border Border.BorderThickness="1" BorderBrush="#A3BDE6" Background="#F7F9FD" Margin="6 0" CornerRadius="4">
                                </Border>
                            </Grid>
                            <StackPanel Margin="10 0" VerticalAlignment="Center">
                                <ContentControl x:Name="HeaderElement" Content="{TemplateBinding Content}" 
                                            ContentTemplate="{TemplateBinding ContentTemplate}"
                                        Control.Foreground="Black" HorizontalAlignment="Left" VerticalAlignment="Center"
                                        FontFamily="Tahoma" FontSize="14" Margin="10 0 0 0"/>
                            </StackPanel>
                        </Grid>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsMouseOver" Value="True">
                                <Setter Property="Visibility" TargetName="SelectedVisualState" Value="Visible"></Setter>
                            </Trigger>
                            <Trigger Property="IsSelected" Value="True">
                                <Setter Property="Visibility" TargetName="SelectedVisualState" Value="Visible"></Setter>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </UserControl.Resources>
    <Grid HorizontalAlignment="Stretch" Height="Auto">
        <ListView ItemsSource="{Binding MenuItems,Mode=TwoWay}" ItemsPanel="{StaticResource ItemsPanelTemplate}"
                  ItemContainerStyle="{StaticResource ListViewItemContainerStyle}" BorderBrush="Transparent" 
                  commad:ListViewSelectionChanged.Command="{Binding SelectionChanged}"
                  SelectedIndex="{Binding SelectedIndex,Mode=TwoWay}"
                  HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
        </ListView>
    </Grid>
</UserControl>
